package cn.stylefeng.guns.modular.business.frequency.transportlevel.mapper;

import cn.stylefeng.guns.modular.business.frequency.transport.model.result.PkgTransport;
import cn.stylefeng.guns.modular.business.frequency.transport.model.result.PkgTransportLevel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.stylefeng.guns.modular.business.frequency.transportlevel.entity.TransportLevel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 运单运输车辆详情 Mapper 接口
 *
 * @author yujie
 * @date 2023/05/09 17:15
 */
public interface TransportLevelMapper extends BaseMapper<TransportLevel> {

    List<TransportLevel> selectGroupByCreateUser(@Param("id") String id);

    /** 根据运单和订单id 查询当前订单的运单分段信息 */
    TransportLevel getLevelByTransportIdAndOrderId(@Param("transportId") Long transportId, @Param("orderId") Long orderId);

    void clearFileUrlByTransportId(@Param("transportId") Long id);

    @Update("update tt_transport_level set has_arrived = 1 where id = #{id}")
    void updateArrivedStatus(@Param("id")Long id);

    @Update("update tt_transport_level set has_arrived = 0 where id = #{id}")
    void updateNotArrivedStatus(@Param("id")Long id);


    //TransportLevel getLevelByTransportIdAndOrderId(@Param("transportId") Long transportId, @Param("orderId") Long orderId);


    int countDistinctCreateUser(@Param("transportId") String transportId);



    int countUnDeliveryCount(@Param("transportId") String transportId, @Param("id") String id);

    int countUnSignedCount(@Param("transportId") String transportId, @Param("id") String id);


    PkgTransport getPkgTransportByLevelId(@Param("transportLevelId") String transportLevelId);


    @Update("update tt_transport_level set file_url = #{result} where id = #{id}")
    void updateFileUrl(@Param("id") String id, @Param("result") String result);


    void updateStatus(@Param("transportLevel") TransportLevel oldTransportLevel);

    PkgTransportLevel getPkgTransportLevelById(@Param("id") String levelId);

}